﻿using AJWPFAdmin.Core.Components.Views;
using AJWPFAdmin.Modules.Main.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace AJWPFAdmin.Modules.Main.Views
{
    /// <summary>
    /// CarIdentificationPanel.xaml 的交互逻辑
    /// </summary>
    public partial class CarIdentificationPanel : UserControl
    {
        public static DependencyProperty IsEntryProperty =
            DependencyProperty.Register(nameof(IsEntry), typeof(bool), typeof(CarIdentificationPanel), new PropertyMetadata(IsEntryPropertyChanged));

        public bool IsEntry
        {
            get { return (bool)GetValue(IsEntryProperty); }
            set { SetValue(IsEntryProperty, value); }
        }

        public static void IsEntryPropertyChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if(sender is CarIdentificationPanel ctrl)
            {
                (ctrl.DataContext as CarIdentificationPanelViewModel).Direction = ctrl.IsEntry
                ? Core.Enums.PassagewayDirection.进 : Core.Enums.PassagewayDirection.出;
            }
        }

        public CarIdentificationPanel()
        {
            InitializeComponent();
            (DataContext as CarIdentificationPanelViewModel).Direction = IsEntry
                ? Core.Enums.PassagewayDirection.进 : Core.Enums.PassagewayDirection.出;
        }
    }
}
